import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
 
const store = new Vuex.Store({
 
  state: {
    // 存储token
    Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : ''
  },
 
  mutations: {
    // 修改token，并将token存入localStorage
    $_setToken(state, value) { // 设置存储token
        state.token = value;
        localStorage.setItem('token', value);
    },
    $_removeStorage(state, value){  // 删除token
        localStorage.removeItem('token');
    },
    changeLogin(state,value){
      state.token = value; //将token放入vue中存储下来
      localStorage.setItem('token', value.Authorization); //将token放入浏览器中的session中 
    }
  }
});
 
export default store;